package com.mornd.gulimall.auth.web.v1;

import com.mornd.gulimall.common.core.constant.LoginConstant;
import com.mornd.gulimall.common.core.constant.ServerUrls;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

/**
 * @author: mornd
 * @dateTime: 2023/8/17 - 23:03
 */

@Controller
public class RouteController {

    /**
     * http://auth.gulimall.com/login.html
     *
     * @return
     */
    @GetMapping({"", "index.html", "login.html", "login"})
    public String toLogin(HttpSession session) {
        if(session.getAttribute(LoginConstant.SESSION_USER) == null) {
            return "login";
        } else {
            return "redirect:" + ServerUrls.PRODUCT;
        }
    }

    /**
     * http://auth.gulimall.com/reg.html
     *
     * @return
     */
    @GetMapping({"reg.html", "reg"})
    public String toReg() {
        return "reg";
    }
}
